package handler

import (
	"github.com/gin-gonic/gin"
	"net/http"
	"superTools-backend/pkg/e"
)

/**
* @Author: super
* @Date: 2020-08-22 09:19
* @Description:
**/

type auth struct {
	Username string `valid:"Required; MaxSize(50)"`
	Password string `valid:"Required; MaxSize(50)"`
}

//用于验证权限
func GetAuth(c *gin.Context) {
	//username := c.Query("username")
	//password := c.Query("password")
	//
	//valid := validation.Validation{}
	//a := auth{Username: username, Password: password}
	//ok, _ := valid.Valid(&a)
	//
	//data := make(map[string]interface{})
	//code := e.INVALID_PARAMS
	//if ok {
	//	isExist := models.CheckAuth(username, password)
	//	if isExist {
	//		token, err := util.GenerateToken(username, password)
	//		if err != nil {
	//			code = e.ERROR_AUTH_TOKEN
	//		} else {
	//			data["token"] = token
	//
	//			code = e.SUCCESS
	//		}
	//
	//	} else {
	//		code = e.ERROR_AUTH
	//	}
	//} else {
	//	for _, err := range valid.Errors {
	//		log.Println(err.Key, err.Message)
	//	}
	//}

	code := e.SUCCESS

	c.JSON(http.StatusOK, gin.H{
		"code" : code,
		"msg" : e.GetMsg(code),
		"data" : "等待添加逻辑",
	})
}